package com.wwwc.util.web;

public class MyMessage  {
    public static StringBuffer htmlMessage (String message) {
	StringBuffer sb = new StringBuffer();
	sb.append("<HTML><HEAD><TITLE>Message</TITLE><HEAD>");
	sb.append("<BODY><CENTER>");
	sb.append(message);
	sb.append("</CENTER>");
	sb.append("</BODY></HTML>");
	return sb;
    }

    public static StringBuffer localHtmlMessage (String message, String user_ip, String local_ips) {
	StringBuffer sb = new StringBuffer("");
	if(user_ip.startsWith(local_ips)) {
	    sb.append("<HTML><HEAD><TITLE>Message</TITLE><HEAD>");
	    sb.append("<BODY><CENTER>");
	    sb.append("<H3>This is local only message</H3>");
	    sb.append("<TABLE width=90%><TR><TD height=100>&nbsp</TD></TR><TR><TD align=center><H3>");
	    sb.append(message);
	    sb.append("</H3></TD></TR></TABLE></CENTER>");
	    sb.append("</BODY></HTML>");
	}
	return sb;
    }

    public static StringBuffer htmlMessage (String mess_local, String mess_user, String user_ip, String local_ips) {
	StringBuffer sb = new StringBuffer("");

	sb.append("<HTML><HEAD><TITLE>Message</TITLE><HEAD>");
	sb.append("<BODY><CENTER>");
	sb.append("<TABLE width=90%><TR><TD height=100>&nbsp</TD></TR><TR><TD align=center><H3>");
	if(user_ip.startsWith(local_ips)) {
	    sb.append("Local Only Message:"+mess_local);
	}
	else {
	    sb.append(mess_user);
	}
	sb.append("</H3></TD></TR></TABLE></CENTER>");
	sb.append("</BODY></HTML>");
	return sb;
    }

    public static StringBuffer htmlMessageForward (String message, String link_name, String link_value, String action) {
	StringBuffer sb = new StringBuffer();
	sb.append("<HTML><HEAD><TITLE>Message&Link</TITLE><HEAD>\n");
	sb.append("<BODY><CENTER><FORM action="+action+"><TABLE width=90%><TR><TD height=100>&nbsp</TD></TR>");
	sb.append("<TR><TD align=center><H3>\n");
	sb.append(message);
	sb.append("</H3></TD></TR>\n");
	sb.append("<TR><TD align=center>\n");
	sb.append("<INPUT TYPE=submit name ="+link_name+" value="+link_value+">\n");
	sb.append("</FORM></TD></TR></TABLE></CENTER>\n");
	sb.append("</BODY></HTML>");
	return sb;
    }

   public static StringBuffer htmlMessage (String message, String back, int step) {
	StringBuffer sb = new StringBuffer();
	sb.append("<HTML><HEAD><TITLE>Message</TITLE><HEAD>\n");
	sb.append("<SCRIPT>\n");
	sb.append("function go_back() {\n");
	sb.append("history.go("+step+");\n");
	sb.append("}\n");
	sb.append("</SCRIPT>\n");
	sb.append("<BODY><CENTER><TABLE width=90%><TR><TD height=100>&nbsp</TD></TR>");
	sb.append("<TR><TD align=center><H3>\n");
	sb.append(message);
	sb.append("</H3></TD></TR>\n");
	sb.append("<TR><TD align=center><FORM>\n");
	sb.append("<INPUT TYPE=button value=Back onClick=\"go_back()\"  style='font-size: 8pt'>\n");
	sb.append("</FORM></TD></TR></TABLE></CENTER>\n");
	sb.append("</BODY></HTML>");
	return sb;
    }

    public static StringBuffer htmlMessageWindowAction (String message, String w_action) {
	StringBuffer sb = new StringBuffer();
	sb.append("<HTML><HEAD><TITLE>Message</TITLE><HEAD>\n");
	sb.append("<SCRIPT>\n");
	sb.append("function window_action() {\n");
	sb.append("window."+w_action+"();\n");
	sb.append("}\n");
	sb.append("</SCRIPT>\n");
	sb.append("<BODY><CENTER><TABLE width=90%><TR><TD height=100>&nbsp</TD></TR>");
	sb.append("<TR><TD align=center><H3>\n");
	sb.append(message);
	sb.append("</H3></TD></TR>\n");
	sb.append("<TR><TD align=center><FORM>\n");
	sb.append("<INPUT TYPE=button value="+w_action.toUpperCase()+" onClick=\"window_action()\">\n");
	sb.append("</FORM></TD></TR></TABLE></CENTER>\n");
	sb.append("</BODY></HTML>");
	return sb;
    }

    public static StringBuffer tableMessage (String message, int font_size) {
	StringBuffer sb = new StringBuffer();
	sb.append("<TABLE><TR><TD align='center' style='font-size: "+font_size+"pt'>");
	sb.append(message);
	sb.append("</TD></TR></TABLE>");
	return sb;
    }
}



